﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>字典明细管理</title>

    <#include "../common/link.ftl" >
    
    <script>
        $(function () {
            //新增和编辑点击时触发一个事件
            $('.btn-input').click(function () {

                if(${qo.parentId}==-1){
                    $.messager.alert("请先选择左面菜单");
                    return;
                };

                //清除模态框的数据
                $("#editModal input").val('');

                $("input[name=parentTitle]").val($("#${qo.parentId}").text());
                $("input[name=parentId]").val(${qo.parentId});

                //获取当前按钮的id值
                //把json转换成js对象
              var json = $(this).data('json');
                if (json) {
                    $("input[name=id]").val(json.id);
                    $("input[name=title]").val(json.title);
                    $("input[name=sequence]").val(json.sequence);
                }
                //调用bootstrap方法弹出窗
                $('#editModal').modal('show');
            });
            
            //提交表单的异步请求
            $('.btn-submit').click(function () {

                $("#editForm").ajaxSubmit(handlerMessage);
            });



             //删除按钮事件
             $('.btn-delete').click(function () {
                //获取当前按钮的id
                 var id =  $(this).data('id');
                 //提示删除确认框
                 $.messager.confirm('提示', '是否删除该数据!', function() { //点击确定后的回调函数
                    $.post('/systemDictionaryItem/delete.do',{id:id}, handlerMessage);
                 });
             });


        });
    </script>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
      <#include "../common/navbar.ftl" >
    <!--菜单回显-->
    <#assign currentMenu="systemDictionaryItem"/>
    <#include "../common/menu.ftl" >
    <div class="content-wrapper">
        <section class="content-header">
            <h1>字典明细管理</h1>
        </section>
        <section class="content">
            <div class="box">

                <div class="row">
                    <div class="col-md-3">
                        <div class="panel panel-default">
                            <div class="panel-heading">字典目录</div>
                            <div class="panel-body">
                                <div class="list-group">

                                 <#list systemDictionarys as d>
                                     <a id="${d.id}" href="/systemDictionaryItem/list.do?parentId=${d.id}"
                                        class="list-group-item ">${d.title}</a>
                                 </#list>
                                    <script>
                                        $("#${qo.parentId}").addClass('active');
                                    </script>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="col-md-9">
                        <!--高级查询--->
                        <form class="form-inline" id="searchForm" action="/systemDictionaryItem/list.do" method="post">
                            <input type="hidden" name="currentPage" id="currentPage" value="1">
                            <input type="hidden" name="parentId"  value="${qo.parentId}">
                            <a href="#" class="btn btn-success btn-input" style="margin: 10px">
                                <span class="glyphicon glyphicon-plus"></span> 添加
                            </a>
                        </form>
                        <#if  qo.parentId gt-1>
                        <!--编写内容-->
                        <div class="box-body table-responsive no-padding ">
                            <table class="table table-hover table-bordered">
                                <tr>
                                    <th>编号</th>
                                    <th>标题</th>
                                    <th>序号</th>
                                    <th>操作</th>
                                </tr>

                        <#list  pageInfo.list as systemDictionaryItem>
                               <tr>
                                   <td>${systemDictionaryItem_index+1}</td>
                                   <td>${systemDictionaryItem.title}</td>
                                   <td>${systemDictionaryItem.sequence}</td>

                                   <td>
                                <@shiro.hasPermission name="systemDictionaryItem:saveOrUpdate">
                                      <a href="#" class="btn btn-info btn-xs btn-input"  data-json='${systemDictionaryItem.json}'">
                                           <span class="glyphicon glyphicon-pencil"></span> 编辑
                                       </a>
                                </@shiro.hasPermission>
                            <@shiro.hasPermission name="systemDictionaryItem:delete">
                                       <a href="#" class="btn btn-danger btn-xs btn-delete" data-id="${systemDictionaryItem.id}">
                                           <span class="glyphicon glyphicon-trash"></span> 删除
                                       </a>
                            </@shiro.hasPermission>
                                   </td>
                               </tr>
                        </#list>

                            </table>
                            <!--分页-->
                    <#include "../common/page.ftl">
                        </div>
                    </div>
                    </#if>
                </div>


            </div>
        </section>
    </div>

    <#include "../common/footer.ftl">
</div>
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
    Launch demo modal
</button>

<!-- 编辑和新增的模态框Modal -->
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="myModalLabel">新增/编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/systemDictionaryItem/saveOrUpdate.do" method="post"
                      id="editForm">
                    <input type="hidden" name="id">
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="intro" class="col-sm-3 control-label">字典目录：</label>
                        <div class="col-sm-6">
                            <input name="parentTitle" class="form-control" readonly>
                            <input type="hidden" name="parentId" class="form-control">
                        </div>
                    </div>
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="title" class="col-sm-3 control-label">明细标题：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="title" name="title"
                                   placeholder="请输入明细标题">
                        </div>
                    </div>
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="sn" class="col-sm-3 control-label">明细序号：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="sequence" name="sequence"
                                   placeholder="请输入明细编码">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary btn-submit">保存</button>
            </div>
        </div>
    </div>
</div>
</body>
</html>
